package com.example.msai.controller;


import com.example.msai.entity.DeepSeekRe;
import com.example.msai.service.DeepSeekService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class DeepSeekController {
    @Autowired
    private DeepSeekService deepSeekService;
    @PostMapping("/DeepSeek")
    public String getAiResponse(@RequestBody DeepSeekRe deepSeekRe) throws IOException, IOException {
        String q = deepSeekRe.getq();
        String res=deepSeekService.getAiResponse(q);
        System.out.println( res);
        String ans = res
                .replaceAll("^```json\\n", "")  // 移除开头的 ```json 和换行
                .replaceAll("\\n```$", "");
        System.out.println( ans);
        return ans;
    }
}
